import 'package:flutter/material.dart';
import 'package:steam_app/config/app_theme.dart';
import '../../entity/product.dart';

class ProductListItem extends StatelessWidget {
  final Product product;

  const ProductListItem({super.key, required this.product});

  @override
  Widget build(BuildContext context) {
    return Card(
      margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 6.0),
      child: Padding(
        padding: const EdgeInsets.all(12.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(product.name, style: const TextStyle(fontSize: titleFontSize, fontWeight: titleFontWeight, color: textColor)),
            if (product.description.isNotEmpty)
              Padding(
                padding: const EdgeInsets.only(top: 4.0),
                child: Text(product.description, style: TextStyle(color: Colors.grey[400])),
              ),
            const SizedBox(height: 12),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  '¥ ${product.price.toStringAsFixed(2)}',
                  style: const TextStyle(fontSize: gameCardTitleFontSize, color: priceTagTextColor, fontWeight: titleFontWeight),
                ),
                ElevatedButton(
                  onPressed: () {
                    //无购物车功能
                  },
                  style: ElevatedButton.styleFrom(
                    backgroundColor: greenButtonColor,
                    foregroundColor: textColor,
                  ),
                  child: const Text('添加至购物车'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}